<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sb" uri="/struts-bootstrap-tags"%>
<%@ include file="/page/company/comHeader.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>配送管理</title>
<script type="text/javascript" src="<%=basePath%>js/tablecreate/jlinq.js"></script>
<script type="text/javascript" src="<%=basePath%>js/tablecreate/jquery-dynamicTable.js"></script>
<script type="text/javascript" src="<%=basePath%>js/tablecreate/pager.js"></script> 
<script type="text/javascript" src="<%=basePath%>js/tablecreate/modal.js"></script>
<style type="text/css">
a:LINK{text-decoration: none;color:black;}
a:visited {text-decoration:none ; color:black;}
a:hover {text-decoration:underline ; color:black;}
a:active {text-decoration:none ; color:black;} 
</style>
<sb:head/>
</head>
<body  onload="comAttenList()">

<h3>配送员列表</h3>

<div style="background-color:#dcdcdc;width: 100%;height:36px;">
<div style="background-color:#dcdcdc;width: 600px;height:36px;float:left;">
<input class="btn btn-info" onclick="plus('atten_editAtten')" type="button" value="添加配送员" /> 
<s:hidden value="%{#session.company.comId}" id="comId"></s:hidden>
<%-- <s:hidden value="%{comId}" id="comId"></s:hidden> --%>
<input id="attName" class="input-medium search-query" name="attName" value=""/>
<select id="status" style="width:120px;">
<option value="">配送员状态</option>
<option value=0>空闲中</option>
<option value=1>配送中</option>
</select>
<input type="button" class="btn btn-success" id="" onclick="searchList()" value="查询"/>
</div>
</div>
<div id="lists" style="width: 100%;height: 400px;">
<div id="list" ></div>
<div id="page"></div>
</div>
<script type="text/javascript">
var comId=$("#comId").val();
var url=[{loadUrl:"atten_getAttens?comId="+comId,editUrl:"<%=basePath%>com/atten_editAtten?attId=",delUrl:""}];//请求地址
var postData={attName:$("#attName").val(),status:$("#status").val()};
var pageId="page";
var objClassName="list_light";
var objColumn = [
					{ ColumnName: "配送员姓名", DataId: "attName", Width: 200, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "配送员区域", DataId: "attAddress", Width: 200, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "配送员状态", DataId: "status", Width: 200, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "创建时间", DataId: "created", Width:200, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "操作", DataId: "Operation", Width: 200, DataAlign: "left", Format: null, OnClick: null },
                 ];
function comAttenList(){
	   $.ajax({
			type: "post",
	        url: url[0].loadUrl,
	        data: postData,
	        dataType: "json",
	        success: function(data){
          var objData = new Array(data.list.length);
          for(var i=0;i<data.list.length;i++){
               var status="";
               if(data.list[i].status==1){
            	   status="配送中";
                   }else{
                	   status="空闲中";
                      }
              var op="<a class='edit' onclick=\"edit('"+url[0].editUrl+""+data.list[i].attId+"')\"   href='javascript:void(0)'  title=\"编辑\"  id='"+data.list[i].attId+"'>编辑</a>&nbsp;&nbsp;";
                op+="<a onclick=\"delInfo('atten_delAtten?attId="+data.list[i].attId+"')\" title='删除' href='javascript:void(0);'>删除</a>";
       	  objData[i]={attName:data.list[i].attName,status:status,attAddress:data.list[i].attAddress,
                	  created:data.list[i].created,Operation:op}; 
              }
               $("#list").MakeTable(objColumn, objData, objClassName);
        	  $("#page").MakePage(data.page[0]);
		        }
			});
	   }
function searchList(){
	var page=$("#selPage").val();
	var pageRow=$("#selRow").val();
	postData={attName:$("#attName").val(),status:$("#status").val(),initPage:page,pageRow:pageRow};
	comAttenList();
}
var j=0;
function OrderSort(order){
	var order=order;
	j++;
	if(j%2==0){
          var sort="desc";
		}else if (j%3==0) {
			var sort="asc";
		}else{
      order="created";
      var sort="desc";
			}
	var page=$("#selPage").val();
	var pageRow=$("#selRow").val();
	postData={attName:$("#attName").val(),status:$("#status").val(),order:order,sort:sort,initPage:page,pageRow:pageRow};
	comAttenList();
}
function goPage(){
	var page=$("#selPage").val();
	var pageRow=$("#selRow").val();
	postData={attName:$("#attName").val(),status:$("#status").val(),initPage:page,pageRow:pageRow};
	comAttenList();
}
function changePage(page){
	var pageRow=$("#selRow").val();
	postData={attName:$("#attName").val(),status:$("#status").val(),initPage:page,pageRow:pageRow};
	comAttenList();
}
function goRow(){
	var pageRow=$("#selRow").val();
	var page=$("#selPage").val();
	comAttenList();
}


</script>
<%@ include file="/page/common/modal.jsp"%>
<jsp:include page="/page/company/comFooter.jsp"></jsp:include>
</body>
</html>